/*
 * Copyright (c) 2025, 廖树财, <study_2030@163.com>
 *
 * PES1.0.3-YCYW is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2     
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#pragma once
#include "define.h"
#include "JsonParser.h"
#include "zlog.h"
#include <upload.h>

typedef struct IOTA_OTA_PARAM
{
    char *fileId;
    char *filename;
    char *fileType;
    int size;
    char *digestAlgorithm;
    char *digest;
    char *fileLink;
    int otaType;
    int pkgSpace;
} IOTA_OTA_PARAM;

typedef struct IOTA_OTA_UPDATE_PARAM
{
    char *patchId;
    char *patchName;
    char *patchVersion;
    char *fileId;
    char *filename;
    int otaType;
    int deviceType;
    char *subDeviceid;
} IOTA_OTA_UPDATE_PARAM;

extern ST_IOTA_LOG_RES *progressDecs;

bool JsonToStruct_DownloadOTAPack(char *pcJson, ST_IOTA_LOG *pcStatusDecs);

int ota_download_file(char *arg);

int ota_download_pthread(char *pcJson);

int ota_download(char *pcJson);

int ota_commond(char *pcJson);
